class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://github.com/offensive-security/exploitdb.git",
      tag:      "2021-09-10",
      revision: "99b8f092133fbe41a4e17d4bff846047643619fc"
  version "2021-09-10"
  license "GPL-2.0-or-later"
  head "https://github.com/offensive-security/exploitdb.git"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_big_sur: "c309cfb3725da80a69b7bf3b551d0e5e81862ad35d7604c43ee92d99e63b500e"
    sha256 cellar: :any_skip_relocation, big_sur:       "e4be5c7e97adf8f38069688b9f4838a7d827725369ea0bf9eeeb6399ca8e7008"
    sha256 cellar: :any_skip_relocation, catalina:      "8e773fe80624d4c829d9287da3241775dcec6a720e5eace1b439c70340996fe9"
    sha256 cellar: :any_skip_relocation, mojave:        "e3b6627f0cb666d01da90d05b9629d30fe1e2d0878aa2096d9428646eebe9b94"
    sha256 cellar: :any_skip_relocation, x86_64_linux:  "aa8573f553165f49a21a008f17ff889976f889184a635b92ac05eb90c1b51366"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
